
unit pasStringDialog;

interface

uses
  Classes,
  Controls,
  Dialogs,
  ExtCtrls,
  Forms,
  Graphics,
  Messages,
  StdCtrls,
  SysUtils,
  Windows, ComCtrls, TFlatButtonUnit;

type
  TfrmStringDialog = class(TForm)
    lblMessage: TLabel;
    txtValue: TEdit;

    bevSeparator: TBevel;
    lstValues: TListBox;
    StatusBar1: TStatusBar;

    procedure FormCreate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
    procedure lstValuesClick(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure txtValueKeyPress(Sender: TObject; var Key: Char);
  private
    pValue: AnsiString;
    procedure wmGetMinMaxInfo( var msgMessage: TMessage ); message WM_GETMINMAXINFO;
  public
  published
    property Value: AnsiString read pValue write pValue;
  end;

var
  frmStringDialog: TfrmStringDialog;

implementation

{$R *.DFM}

procedure TfrmStringDialog.wmGetMinMaxInfo( var msgMessage: TMessage );
begin

  inherited;

  with pMinMaxInfo( msgMessage.lparam )^ do
  begin
    with ptMinTrackSize do
    begin
      X := 350;
      Y := 250;
    end;//with

    with ptMaxTrackSize do
    begin
      X := High( Word );
      Y := High( Word );
    end;//with
  end;//with

end;

//_____________________________________________________________________________

procedure TfrmStringDialog.FormCreate(Sender: TObject);
begin
  if Screen.Fonts.IndexOf( 'Tahoma' ) >- 1 then
  begin
    Font.Name := 'Tahoma';
    Font.Charset := EASTEUROPE_CHARSET;
  end;//if

  {
  btnOK.Font := Font;
  btnCancel.Font := Font;
  }
end;

//_____________________________________________________________________________

procedure TfrmStringDialog.btnOKClick(Sender: TObject);
begin
  Value := txtValue.Text;
  ModalResult := mrOK;
end;

//_____________________________________________________________________________

procedure TfrmStringDialog.btnCancelClick(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

//_____________________________________________________________________________

procedure TfrmStringDialog.lstValuesClick(Sender: TObject);
var
  intgA: Integer;
  boolA: Boolean;
begin
  boolA := False;

  for intgA := 0 to lstValues.Items.Count - 1 do
  begin
    if lstValues.Selected[intgA] = True then
    begin
      if boolA = False then
      begin
        txtValue.Text := lstValues.Items[intgA];
        boolA := True;
      end
      else
      begin
        txtValue.Text := Format( '%s %s', [txtValue.Text, lstValues.Items[intgA]] );
      end;//if
    end;//if
  end;//for
end;

procedure TfrmStringDialog.FormResize(Sender: TObject);
begin

  lstValues.Height := Height - 99;
  bevSeparator.Height := Height - 56;

  lblMessage.Width := Width - 120;
  txtValue.Width := lblMessage.Width;
  lstValues.Width := lblMessage.Width;

  bevSeparator.Left := Width - 106;
  //btnOK.Left := Width - 97;
  //btnCancel.Left := Width - 97;
end;

procedure TfrmStringDialog.txtValueKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then btnOKClick( Sender );
end;

end.
